﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace Gencode.Controls.Harmonica
{
	[ToolboxItem(false)]
	public partial class Harmonica : Control
	{
		HarmonicaNodeCollection nodes;

		//Button btn;

		public Harmonica()
		{
			InitializeComponent();

			nodes = new HarmonicaNodeCollection(this);

			/*
			button = new HarmonicaButton(this);
			button.Text = "button 1";
			button.Location = new Point(0, 0);
			button.Size = new Size(this.ClientRectangle.Width, 40);
			*/

			//btn = new Button();

			//this.SuspendLayout();
			//btn.Location = new Point(button.Location.X, button.Location.Y + button.Size.Height);
			//btn.Size = new Size(this.Size.Width, 40);
			//btn.Text = "test 2";

			//this.Controls.Add(btn);
			//this.ResumeLayout(false);
		}

		private void Harmonica_Paint(object sender, PaintEventArgs e)
		{
			Graphics g = e.Graphics;
			
			g.FillRectangle(Brushes.Yellow, ClientRectangle);
			g.DrawString("Hello, world", Font, Brushes.Black, 0, 0);

			//foreach (HarmonicaNode node in Nodes)
			//    node.NodeButton.HarmonicaButton_Paint(this, g);

			Rectangle r = ClientRectangle;
			//r.Inflate(-4, -4);
			r.Width--;
			r.Height--;
			Pen p = new Pen(Color.Black, 1);
			p.DashStyle = System.Drawing.Drawing2D.DashStyle.Solid;
			g.DrawRectangle(p, r);
		}

		int pageCount = 1;
		public int PageCount
		{
			get
			{
				return pageCount;
			}
		}

		private void Harmonica_SizeChanged(object sender, EventArgs e)
		{
			foreach (HarmonicaNode node in Nodes)
				node.NodeButton.Size = new Size(this.Size.Width, node.NodeButton.Size.Height);
		}

		public HarmonicaNodeCollection Nodes
		{
			get
			{
				return nodes;
			}
		}
	}
}
